package com.ptp.backendcertms.business.controller;

import com.ptp.backendcertms.api.external.dto.req.QueryResultDetailReqDto;
import com.ptp.backendcertms.api.external.dto.req.QueryResultListReqDto;
import com.ptp.backendcertms.api.external.dto.res.QueryResultListResDto;
import com.ptp.backendcertms.api.external.dto.res.ResponseDto;
import com.ptp.backendcertms.basiccompnents.http.ResponseWrapper;
import com.ptp.backendcertms.business.service.IOrganizationQueryService;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

/**
 * pc/h5认证信息查询相关接口
 */
@RestController
@RequestMapping("/cms")
public class OrganizationQueryController {

    @Resource
    private IOrganizationQueryService organizationQueryService;


    /**
     * 认证信息查询接口
     *
     * @param reqDto 请求参
     */
    @RequestMapping(value = "/organizationQuery/queryList", method = RequestMethod.POST)
    public ResponseDto<QueryResultListResDto> list(@RequestBody @Valid QueryResultListReqDto reqDto, BindingResult bindingResult) {
        return ResponseWrapper.responseReturnWithValid(bindingResult, "[PC/H5端]-认证信息列表查询接口",
                () -> organizationQueryService.list(reqDto));
    }


    /**
     * 根据证书编号查询详情
     *
     * @param reqDto 请求参
     */
    @RequestMapping(value = "/organizationQuery/queryDetail", method = RequestMethod.POST)
    public ResponseDto<Map<String,Object>> detail(@RequestBody @Valid QueryResultDetailReqDto reqDto, BindingResult bindingResult) {
        return ResponseWrapper.responseReturnWithValid(bindingResult, "[PC/H5端]-认证信息详情查询接口",
                () -> organizationQueryService.detail(reqDto));
    }

}
